// C++标准的头文件
#include <iomanip>
// G4定义的头文件
#include "G4UnitsTable.hh"      // G4中物理量的单位转换和显示工具
#include "G4VVisManager.hh"     // G4可视化管理基类
#include "G4VisAttributes.hh"   // G4外观管理类
#include "G4Circle.hh"          // G4圆形
#include "G4Color.hh"           // G4Color
// 用户定义的头文件
#include "G4ImproveHit.hh"

// Hit的分配器
G4ThreadLocal G4Allocator<G4ImproveHit>* G4ImproveHitAllocator = nullptr;

// 相等操作符重载的函数实现
G4bool G4ImproveHit::operator==(const G4ImproveHit& right) const{
  return ( this == &right ) ? true : false;
}

// Draw方法的实现（在可视化中绘图）
void G4ImproveHit::Draw(){
    G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
        if(pVVisManager){
        G4Circle circle(fPos);
        circle.SetScreenSize(4.);
        circle.SetFillStyle(G4Circle::filled);
        G4VisAttributes attribs(G4Colour::Red());
        circle.SetVisAttributes(attribs);
        pVVisManager->Draw(circle);
  }
}

// Print方法的实现（在终端中打印）
void G4ImproveHit::Print(){
  G4cout
  << "eventID: "    << fEventID << "\t"
  << "trackID: "    << fTrackID << "\t"
  << "chamberNb: "  << fChamberNb << "\t"
  << "Edep: "       << std::setw(7) << G4BestUnit(fEdep,"Energy") << "\t"   // 将能量值格式化为合适的单位
  << "Position: "   << std::setw(7) << G4BestUnit( fPos,"Length")           // 将位置格式化为适当的长度单位
  << G4endl;
}